//
//  KZRebateSearchBar.swift
//  BoyeStore
//
//  Created by 朱凯 on 2018/6/27.
//  Copyright © 2018年 itboye. All rights reserved.
//

import UIKit

class KZRebateSearchBar: UIView {
    
    let searchTextField = UITextField()

    convenience init() {
        self.init(frame: .zero)
        
        setupUI()
    }
}

// MARK: ------ 创建视图
extension KZRebateSearchBar {
    
    func setupUI() {
        
        self.backgroundColor = UIColor.white
        self.layer.cornerRadius = 4
        self.layer.masksToBounds = true
        
        let rightButton = UIButton()
        rightButton.layer.cornerRadius = 4
        rightButton.layer.masksToBounds = true
        rightButton.backgroundColor = kThemeColor
        rightButton.setTitleColor(UIColor.white, for: .normal)
        rightButton.setTitle("搜返利", for: .normal)
        rightButton.titleLabel?.font = kFont(14)
        self.addSubview(rightButton)
        rightButton.snp.makeConstraints { (m) in
            m.right.equalTo(-10)
            m.centerY.equalTo(self)
            m.height.equalTo(30)
            m.width.equalTo(70)
        }
        
        let searchIconView = UIImageView()
        searchIconView.image = #imageLiteral(resourceName: "搜索-搜索icon")
        self.addSubview(searchIconView)
        searchIconView.snp.makeConstraints { (m) in
            m.left.equalTo(10)
            m.width.height.equalTo(15)
            m.centerY.equalTo(self)
        }
        

        self.addSubview(searchTextField)
        searchTextField.placeholder = "复制商品标题，拿返利更精准"
        searchTextField.font = kFont(14)
        searchTextField.textColor = kThemeColor
        searchTextField.snp.makeConstraints { (m) in
            m.left.equalTo(searchIconView.snp.right).offset(10)
            m.right.equalTo(rightButton.snp.left).offset(-10)
            m.top.bottom.equalTo(0)
        }
    }
}



